/*
 * @Description: 
 * @Author: zoe
 * @Date: 2024-09-20 18:33:42
 * @LastEditors: rendc
 * @LastEditTime: 2024-09-20 18:38:35
 */
public class TestAction {
    public static void main(String[] args) {
        //使用匿名内部类实现Action接口
        Action action1 = new Action(){
            @Override
            public String[] test(String str) {
                return str.split("\\|");
            }
        };
        Action action2 = new Action(){
            @Override
            public String[] test(String str) {
                return str.split("-");
            }
        };
        //测试使用\作为分隔符的情况
        String[] result1 = action1.test("a|b|c|");
        for (String str : result1) {
            System.out.println(str);
        }
        //测试使用-作为分隔符的情况
        String[] result2 = action2.test("a-b-c");
        for (String str : result2) {
            System.out.println(str);
        }
    }
}
